package com.example.administrator.ac;

import android.app.Fragment;
import android.os.Bundle;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.SearchView;
import android.widget.TextView;

import listclick.OrderList;

/**
 * Created by Administrator on 2017/6/27.
 */

public class MyFragment extends Fragment implements View.OnClickListener{
    private ListView listview;
    private int page = 0;
    private TextView searchbutton;
    private EditText searchtext;
    private OrderList i;
    public MyFragment(int page) {

        this.page = page;
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

        View view = inflater.inflate(page, container, false);

        switch (page) {
            case R.layout.unprocessorderpage:
                listview = (ListView) view.findViewById(R.id.unprocesslistview);
               i = new OrderList(listview);
               i.setUnprocessList();
                searchbutton=(TextView)view.findViewById(R.id.usearchbutton) ;
                searchtext=(EditText)view.findViewById(R.id.usearchtext);
                break;
            case R.layout.historyorderpage:
                listview = (ListView) view.findViewById(R.id.historylistview);
                i= new OrderList(listview);
                i.setUnprocessList();
                searchbutton=(TextView)view.findViewById(R.id.hsearchbutton) ;
                searchtext=(EditText)view.findViewById(R.id.hsearchtext);


                break;
            case R.layout.careworkerpage:
                return view;

        }

        searchbutton.setOnClickListener(this);
        return view;
    }

    //搜索事件处理
    @Override
    public void onClick(View v) {
        i.searchList(searchtext.getText().toString());
    }
}


